void main() {
  // 准备购物车数据
  List carts = [
    {"count": 2, "price": 10.0, "selected": true},
    {"count": 1, "price": 30.0, "selected": true},
    {"count": 5, "price": 20.0, "selected": true},
  ];

  // 调用封装的函数
  getSelectInfo(carts) ? print('全选') : print('非全选');
}

// 核心逻辑：只要有任何一个商品是未勾选的，那么就是非全选
bool getSelectInfo(List carts) {

  bool isSelected = true;

  // carts.forEach((item){
  //   if(!item['selected']){
  //     isSelected = false;
  //   }
  // });

  for(var i = 0 ; i < carts.length; i++){
    if(!carts[i]['selected']){
      isSelected = false;
      break;
    }
  }

  return isSelected;

}
